
$(function () {
    function init() {
        $.ajax({
            url: bignews.category_list,
            headers: { Authorization: localStorage.getItem('bignews-token') },
            success: function (res) {
                $('tbody').html(template('cateTemp', res))
            },
            dataType: 'json'
        })
    }
    init()
    // 新增
    $('.btnOpt').on('click', function () {
        let name = $('#cateName').val().trim()
        let slug = $('#cateSlug').val().trim()
        $.ajax({
            type: 'post',
            url: bignews.category_add,
            data: { name, slug },
            headers: { Authorization: localStorage.getItem('bignews-token') },
            success: function (res) {
                console.log(res);
                $('#cateModal').modal('hide')
                init()
                $('#cateName').val('')
                $('#cateSlug').val('')
            },
            dataType: 'json'
        })
    })


})